package LeetCode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}14:22
 */
public class interview45 {
    public static void main(String[] args) {
        int[] result = {10,2};
        System.out.println(new interview45().minNumber(result));
    }

    public String minNumber(int[] nums) {
        List<String> stringList = new ArrayList<>();
        for (int num : nums) {
            stringList.add(String.valueOf(num));
        }
        Collections.sort(stringList, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return (o1+o2).compareTo(o2+o1);
            }
        });

//        stringList.sort((o1, o2) -> (o1+o2).compareTo(o2+o1));
        StringBuilder stringBuilder = new StringBuilder();
        stringList.forEach(s -> stringBuilder.append(s));
        return stringBuilder.toString();
    }
}
